<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="width=device-width,minimum-scale=1,maximum-scale=1,user-scalable=no;">
    <title>认证</title>
    <script src="js/jquery.min.js"></script>
    <script src="js/alert.js"></script>
    <link rel="stylesheet" href="css/weui.css"/>
</head>

<body>
<div class="page">
    <div class="weui-form">
        <div class="weui-form__text-area">
            <div class="weui-form__desc">填写手机号</div>
        </div>
        <div class="weui-form__control-area">
            <div class="weui-cells__group weui-cells__group_form">
                <div class="weui-cells weui-cells_form">
                    <div class="weui-cell">
                        <div class="weui-cell__hd"><label class="weui-label">手机号</label></div>
                        <div class="weui-cell__bd">
                            <input id="phone" class="weui-input" type="number" pattern="[0-9]*" placeholder="请输入手机号"
                                   value=""/>
                        </div>
                        <div class="weui-cell__ft">
                            <button class="weui-btn_reset weui-btn_icon">
                                <i id="showIOSDialog1" class="weui-icon-info-circle"></i>
                            </button>
                        </div>
                    </div>

                   <!-- <div class="weui-cell weui-cell_vcode">
                        <div class="weui-cell__hd"><label class="weui-label">验证码</label></div>
                        <div class="weui-cell__bd">
                            <input autofocus class="weui-input" type="text" pattern="[0-9]*" id="js_input"
                                   placeholder="输入验证码" maxlength="6"/>
                        </div>
                        <div class="weui-cell__ft">
                            <button id="send" style="width: 110%;" class="weui-btn weui-btn_default weui-vcode-btn">
                                获取验证码
                            </button>
                        </div>
                    </div>-->

                </div>
            </div>
        </div>

        <div class="weui-form__opr-area">
            <a class="weui-btn weui-btn_primary <!--weui-btn_disabled-->" href="javascript:" id="showTooltips">确定</a>
        </div>
    </div>
    <div id="js_toast" style="display: none;">
        <div class="weui-mask_transparent"></div>
        <div class="weui-toast">
            <i class="weui-icon-success-no-circle weui-icon_toast"></i>
            <p class="weui-toast__content">已完成</p>
        </div>
    </div>
    <div id="dialogs">
        <!--BEGIN dialog1-->
        <div class="js_dialog" id="iosDialog1" style="display: none;">
            <div class="weui-mask"></div>
            <div id="js_half_screen_dialog" class="weui-half-screen-dialog">
                <div class="weui-half-screen-dialog__hd">
                    <div class="weui-half-screen-dialog__hd__side">
                        <button id="dialogClose" class="weui-icon-btn weui-icon-btn_close">关闭</button>
                    </div>
                    <div class="weui-half-screen-dialog__hd__main">
                        <strong class="weui-half-screen-dialog__title">帮助</strong>
                    </div>
                </div>
                <div class="weui-half-screen-dialog__bd">
                    <br>
                    <br>
                    输入注册用的手机号
                    <br>
                    <br>
                    <br>
                    <br>
                </div>
            </div>
        </div>
    </div>
</div>

</body>
<script>

    var timeI;
    var i = 60;

    $("#send").click(function () {
        Send();
    });

    $("#showTooltips").click(function () {
        Verify1();
    });
    //判断验证码
    function Verify1() {
        $.ajax({
            "url": "/checkcode/verify/",
            "data": "phone=" + $("#phone").val() + "&code=" + $("#js_input").val(),
            "type": "POST",
            "dataType": "json",
            "success": function (json) {
                if (json.state == 200) {
                    Verify2();
                } else {
                   alert(json.message);

                }
            }
        })
    }
//判断vip是否bos存在
    function Verify2() {
        $.ajax({
            "url": "/wechat/roc/",
            "data": "phone=" + $("#phone").val() + "&code=" + $("#js_input").val(),
            "type": "POST",
            "dataType": "json",
            "success": function (json) {
                if (json.state == 200) {

                    location.href = "user.html"
                } else {
                    location.href = "attestation.html"
                }
            }
        })
    }

    function Send() {
        $.ajax({
            "url": "/checkcode/code/",
            "data": "phone=" + $("#phone").val(),
            "type": "POST",
            "dataType": "json",
            "success": function (json) {
                if (json.state == 200) {
                    cl();
                } else {
                    alert(json.message);
                }
            }
        })
    }

    function cl() {
        $("#send").attr("disabled", "true");
        $("#send").css("color", "#33333099");
        $("#send").html('重新发送:60');

        timeI = setInterval(ms, 1000);
    }

    function ms() {
        $("#send").html('重新发送:' + --i);
        if (i == 0) {
            i = 60;
            $("#send").css("color", "#06AE56");
            $("#send").removeAttr("disabled");
            $("#send").html('获取验证码 ');
            clearInterval(timeI);
            return;
        }
    }
</script>

<script type="text/javascript">
    $(function () {
        var $tooltips = $('.js_tooltips');
        var $toast = $('#js_toast');
        var $input = $('#js_input');
        var $agree = $('#weuiAgree');
        var $agreeCheckbox = $('#weuiAgreeCheckbox');
        var $halfScreenDialog = $('#js_half_screen_dialog');

        $input.on('input', function () {
            var $value = $input.val();
            if ($value) {
                $('#showTooltips').removeClass('weui-btn_disabled');
            } else {
              //  $('#showTooltips').addClass('weui-btn_disabled');
            }
        });


        $('#showTooltips').on('click', function () {
            if ($(this).hasClass('weui-btn_disabled')) return;
            if ($tooltips.css('display') != 'none') return;
            // toptips的fixed, 如果有`animation`, `position: fixed`不生效
            $('.page.cell').removeClass('slideIn');

            if ($agreeCheckbox.prop("checked")) {
                $toast.fadeIn(100);
                setTimeout(function () {
                    $toast.fadeOut(100);
                }, 2000);
            } else {
                $agree.addClass('weui-agree_animate');
                setTimeout(function () {
                    $agree.removeClass('weui-agree_animate');
                }, 1000);
            }
        });

        var $iosDialog1 = $('#iosDialog1');

        $('#dialogs').on('click', '.weui-mask', function () {
            $halfScreenDialog.removeClass('weui-half-screen-dialog_show');
            $(this).parents('.js_dialog').fadeOut(200);
        });
        $('#dialogClose').on('click', function () {
            $halfScreenDialog.removeClass('weui-half-screen-dialog_show');
            $(this).parents('.js_dialog').fadeOut(200);
        });

        $('#showIOSDialog1').on('click', function () {
            $iosDialog1.fadeIn(200);
            $halfScreenDialog.addClass('weui-half-screen-dialog_show');
        });
    });

</script>

</html>